﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace Tailoring
{
    public partial class frmorderprint : Form
    {
        int cid=0;

        public int Cid
        {
            get { return cid; }
            set { cid = value; }
        }
        int oid=0;

        public int Oid
        {
            get { return oid; }
            set { oid = value; }
        }
        public frmorderprint()
        {
            InitializeComponent();
        }
        public void retriveorderid()
        {
            try
            {
                SqlConnection conn = new SqlConnection("Server= localhost; database=tailoringmng; integrated Security=true");
                conn.Open();
                string strquery = "select Top 1 tblorder.orderId from tblorder ORDER BY tblorder.orderId DESC";
                SqlCommand sqlcmd = new SqlCommand(strquery, conn);
                
                SqlDataReader sqldreader = sqlcmd.ExecuteReader();

                while (sqldreader.Read())
                {
                    oid = Convert.ToInt32(sqldreader["orderId"].ToString());
                }


            }
            catch { }
        }

        private void frmorderprint_Load(object sender, EventArgs e)
        {
            retriveorderid();
            // TODO: This line of code loads data into the 'dsorder.DataTable1' table. You can move, or remove it, as needed.
            this.DataTable1TableAdapter.Fill(this.dsorder.DataTable1,cid,oid);

            this.reportViewer1.RefreshReport();
        }
    }
}
